package org.dromara.business.utils;

import java.security.SecureRandom;
import java.util.Base64;

public class SecureInviteCodeGenerator {
    private static final SecureRandom random = new SecureRandom();

    public static String generate() {
        byte[] bytes = new byte[4];
        random.nextBytes(bytes);
        return Base64.getUrlEncoder()
                   .withoutPadding()
                   .encodeToString(bytes)
                   .substring(0, 6)
                   .toUpperCase()
                   .replaceAll("[^A-Z0-9]", "A"); // 替换掉非字母数字字符
    }

    public static void main(String[] args) {
        System.out.println(generate());
    }
}
